<%= form_for(@template_field, :html => {:id => "template_field_form"}) do |f| %>
  <% if @template_field.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@template_field.errors.count, "error") %> prohibited this template_field from being saved:</h2>

      <ul>
      <% @template_field.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label "Values" %>
    <div id="field_values" class="ui-corner-all">
      <ul id="values_list">
        <% if controller.action_name == "edit" %>
          <% @template_field.field_values.each {|v| %>
            <script>add_value("<%= v.value %>")</script>
          <% } %>
        <% end %>
      </ul>
    </div><br />
    <%= f.label "New value" %> <br />
    <%= text_field_tag "new_value" %> <%= tag :input, :type => "button", :id => "new_value_button", :value => "Add value", :onclick => " add_value($('#new_value').attr('value'))" %> (No comma allowed).
  </div>
  <div class="field">
    <%= f.label :tech_col_name %><br />
    <%= f.select 'tech_col_name', tech_col_names %>
  </div>
  <div class="field">
    <%= f.label :field_category_id %><br />
    <%= f.select 'field_category_id', FieldCategory.all.collect {|c| [c.name, c.id]} %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

